package com.shy.autoproxy.cglib;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class DataBaseServiceCallback implements MethodInterceptor {
    private Object target;

    public DataBaseServiceCallback(Object target) {
        this.target = target;
    }
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        System.out.println("数据库连接前");
        Object returnValue = proxy.invoke(target, args);
        System.out.println("数据库连接后");
        return returnValue;
    }
}
